package com.itheima.demo.demo11;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServiceUpLoad {
    public static void main(String[] args) throws IOException {
        ServerSocket sev=new ServerSocket(8888);
        Socket socket = sev.accept();
        InputStream is=  socket.getInputStream();
        FileOutputStream fos=new FileOutputStream("D:\\2345Downloads\\诗.jpg");
        int len=0;
        byte[]buf=new byte[1024];
        while ((len=is.read(buf))!=-1){
            fos.write(buf,0,len);
        }
        System.out.println("服务器：文件已经保存到服务器");
        fos.close();
        sev.close();
        socket.close();
    }
}
